import numpy as np

# (1) 创建数据
temps = np.random.uniform(10, 35, size=(7, 7))

# (2) 设置特殊值
temps[2, 4] = np.nan
temps[5, 1] = np.inf

# (3) 输出属性
print("原始气温数据：\n", temps)
print("\n数组形状:", temps.shape)
print("数据类型:", temps.dtype)
print("维度数:", temps.ndim)

# 广播操作
temps_adjusted = temps + 1.5
print("\n调整后气温数据：\n", temps_adjusted)

# 验证广播
print("\n验证广播效果:")
print("第一行第一列原始值:", temps[0,0])
print("第一行第一列调整值:", temps_adjusted[0,0])

# import numpy as np
#
# temps = np.random.uniform(0, 40, size=(7, 7))
# temps[2, 4] = np.nan
# temps[5, 1] = np.inf
# print("缺失值位置(2,4):", temps[2, 4])
# print("异常值位置(5,1):", temps[5, 1])
#
# print("气温数据：\n", temps)
# print("数组形状：", temps.shape)
# print("数据类型：", temps.dtype)
#
# temps_adjusted = temps + 1.5
# print("升温后气温：\n", temps_adjusted)
#
# # 检查第0行第0列元素的计算
# original = temps[0, 0]
# adjusted = temps_adjusted[0, 0]
# print("原始值:", original, "→ 调整后:", adjusted)
# print("差值是否为1.5:", np.isclose(adjusted - original, 1.5))